package org.cs2340.jellybeanwms.views;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.cs2340.jellybeanwms.model.InMemoryModel;
import org.cs2340.jellybeanwms.model.Person;
import org.cs2340.jellybeanwms.presenters.PersonListingPresenter;
import org.cs2340.jellybeanwms.support.MyPersonListAdapter;

import android.os.Bundle;
import android.app.Activity;
import android.app.ListActivity;
import android.util.Log;
import android.view.Menu;

/**
 * Our activity to show all the people in a list view
 * Since we derive from ListActivity, then we don't need
 * a special layout.xml file.
 * 
 * @author Robert
 *
 */
public class PersonListingActivity extends ListActivity implements IPersonListingView {

	/** the people to display in the activity */
	private Person[] people;
	/** the presenter to use */
	private PersonListingPresenter myPresenter;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//make our presenter
		myPresenter = new PersonListingPresenter(new InMemoryModel(), this);
		//now make an instance of our adapter so that the data can be displayed
		MyPersonListAdapter adapt = new MyPersonListAdapter(this, people);
		//tell this list view to use the adapter
		setListAdapter(adapt);
		Log.d("Model", "Set adapter");
	}

	/*
	 * Called by the presenter to set the people that this list will display.
	 * 
	 * (non-Javadoc)
	 * @see edu.gatech.oad.simplemvp.views.IPersonListingView#setPeople(edu.gatech.oad.simplemvp.model.Person[])
	 */
	@Override
	public void setPeople(Person[] p) {
		people =p;		
	}

}
